home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12753 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  48 lines

  1. Path: anvil.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Looking for semaphore example.
  5. Date: 2 Apr 1996 09:31:00 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4jro8kINN85c@anvil.ugrad.cs.ubc.ca>
  8. References: <4jc5hd$1vlv@ilx018.iil.intel.com> <4jlc0k$j02@solutions.solon.com> <828366149snz@genesis.demon.co.uk> <4jq01e$9kq@solutions.solon.com>
  9. NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
  10.  
  11. In article <4jq01e$9kq@solutions.solon.com>,
  12. Peter Seebach <seebs@solutions.solon.com> wrote:
  13. >In article <828366149snz@genesis.demon.co.uk>,
  14. >Lawrence Kirby  <fred@genesis.demon.co.uk> wrote:
  15. >>>Unless you wanted to implement software-level coprocesses or the like,
  16. >>>which you could do.
  17. >
  18. >>Strictly conforming?
  19. >
  20. >Sure.  You could write strictly conforming C which parses and translates
  21. >one or more programs in an arbitrary language, and gives them various
  22. >"calls" they can make, which could include semaphores.
  23.  
  24. Or how about this:
  25.  
  26. #include <stdio.h>
  27.  
  28. char *semprog =
  29.     "#include <stdio.h>\n";
  30.     "#include <semctl.h>\n";
  31.     "int main()\n";
  32.     "/* et cetera... code which uses semaphores */\n";
  33.  
  34. int main()
  35.  
  36. {
  37.     FILE *f = fopen("semprog.c","w");
  38.     if (f) {
  39.         fputs(semprog, f);
  40.         fclose(f);
  41.         system("cc semprog.c");
  42.         system("a.out");
  43.     }
  44.     return 0;
  45. }
  46. -- 
  47.  
  48.